/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import componenten.Database;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import model.Leden;
import model.Lid;

/**
 *
 * @author Gebruiker
 */
public class LidWijzigen extends javax.swing.JFrame {

    private Lid clsLid;

    /**
     * Creates new form ToernooiAanmaken
     */
    public LidWijzigen(String argId) {

        initComponents();

        Lid lid = new Lid(argId);
        this.clsLid = lid;

        this.txtVoornaam.setText(this.clsLid.getVoornaam());
        this.txtAchternaam.setText(this.clsLid.getAchternaam());
        this.txtTussenvoegsel.setText(this.clsLid.getTussenvoegsels());
        this.txtGeboortedatum.setText(this.clsLid.getGeboortedatum());
        this.txtEmail.setText(this.clsLid.getEmail());
        this.txtTelefoon.setText("" + this.clsLid.getTelefoon());
        this.txtWoonplaats.setText(this.clsLid.getWoonplaats());
        this.txtStraat.setText(this.clsLid.getStraat());
        this.txtHuisnummer.setText(this.clsLid.getHuisnummer());
        this.txtPostcode.setText(this.clsLid.getPostcode());
        this.cboStatus.setSelectedItem(this.clsLid.getStatus());

        this.btnAanmaken.setText("Bijwerken");
    }

    public LidWijzigen() {
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cboStatus = new javax.swing.JComboBox();
        txtAchternaam = new javax.swing.JTextField();
        txtGeboortedatum = new javax.swing.JTextField();
        txtTussenvoegsel = new javax.swing.JTextField();
        txtTelefoon = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        txtWoonplaats = new javax.swing.JTextField();
        txtStraat = new javax.swing.JTextField();
        txtHuisnummer = new javax.swing.JTextField();
        txtPostcode = new javax.swing.JTextField();
        btnAanmaken = new javax.swing.JButton();
        txtVoornaam = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        lblStatus = new javax.swing.JLabel();
        CancelBtn = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("LID WIJZIGEN");
        setMinimumSize(null);

        jLabel4.setText("Geboortedatum:");

        jLabel5.setText("Email:");

        jLabel2.setText("Achternaam:");

        jLabel3.setText("Tussenvoegsel:");

        cboStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "actief", "inactief" }));
        cboStatus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboStatusActionPerformed(evt);
            }
        });

        txtTelefoon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtTelefoonActionPerformed(evt);
            }
        });

        txtStraat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtStraatActionPerformed(evt);
            }
        });

        btnAanmaken.setText("Bijwerken");
        btnAanmaken.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAanmakenActionPerformed(evt);
            }
        });

        jLabel1.setText("Voornaam:");

        jLabel10.setText("Postcode:");

        jLabel9.setText("Huisnummer:");

        jLabel8.setText("Straat:");

        jLabel7.setText("Woonplaats:");

        jLabel6.setText("Telefoon:");

        lblStatus.setText("Status:");

        CancelBtn.setText("Cancel");
        CancelBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnAanmaken)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(CancelBtn))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9)
                            .addComponent(jLabel10)
                            .addComponent(lblStatus))
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(cboStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtVoornaam)
                            .addComponent(txtAchternaam)
                            .addComponent(txtTussenvoegsel)
                            .addComponent(txtGeboortedatum)
                            .addComponent(txtEmail)
                            .addComponent(txtTelefoon)
                            .addComponent(txtWoonplaats)
                            .addComponent(txtStraat)
                            .addComponent(txtHuisnummer)
                            .addComponent(txtPostcode, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtVoornaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtAchternaam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtTussenvoegsel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtGeboortedatum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtTelefoon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtWoonplaats, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtStraat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtHuisnummer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txtPostcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cboStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblStatus))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAanmaken)
                    .addComponent(CancelBtn))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cboStatusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboStatusActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cboStatusActionPerformed

    private void txtTelefoonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTelefoonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtTelefoonActionPerformed

    private void txtStraatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtStraatActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtStraatActionPerformed

    private void btnAanmakenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAanmakenActionPerformed

        clsLid.setVoornaam(txtVoornaam.getText());
        clsLid.setAchternaam(txtAchternaam.getText());
        clsLid.setTussenvoegsels(txtTussenvoegsel.getText());
        clsLid.setGeboortedatum(txtGeboortedatum.getText());
        clsLid.setEmail(txtEmail.getText());
        clsLid.setTelefoon(txtTelefoon.getText());
        clsLid.setWoonplaats(txtWoonplaats.getText());
        clsLid.setStraat(txtStraat.getText());
        clsLid.setHuisnummer(txtHuisnummer.getText());
        clsLid.setPostcode(txtPostcode.getText());
        clsLid.setStatus((String)cboStatus.getSelectedItem());

        clsLid.bijwerken();

        if (clsLid.isGevalideerd()) {
            this.setVisible(false);

        } else {
            String bericht = "";
            ArrayList berichten = clsLid.getBericht();
            for (int i = 0; i < berichten.size(); i++) {
                bericht = bericht + (String) berichten.get(i) + "\n";
            }

            JOptionPane.showMessageDialog(null, bericht);
            clsLid.resetBericht();
        }
    }//GEN-LAST:event_btnAanmakenActionPerformed

    private void CancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelBtnActionPerformed
        this.dispose();
    }//GEN-LAST:event_CancelBtnActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(LidWijzigen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LidWijzigen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LidWijzigen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LidWijzigen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LidWijzigen().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelBtn;
    private javax.swing.JButton btnAanmaken;
    private javax.swing.JComboBox cboStatus;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JTextField txtAchternaam;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtGeboortedatum;
    private javax.swing.JTextField txtHuisnummer;
    private javax.swing.JTextField txtPostcode;
    private javax.swing.JTextField txtStraat;
    private javax.swing.JTextField txtTelefoon;
    private javax.swing.JTextField txtTussenvoegsel;
    private javax.swing.JTextField txtVoornaam;
    private javax.swing.JTextField txtWoonplaats;
    // End of variables declaration//GEN-END:variables
}
